Add parser to distinguish valid DAB variable interpolation from bash variables in scripts #4197
Open
AryanBagade wants to merge 3 commits intodatabricks:mainfrom
Open
Conversation
…variables in scripts (databricks#4179) Signed-off-by: Aryan Bagade <aryan@aryanbagade.com>
Author
|
@shreyas-goenka could you please review this PR. |
|
An authorized user can trigger integration tests manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
Add a parser to properly distinguish valid DAB variable interpolation from bash environment variables in scripts.
FindAllInterpolationReferences()andHasValidDABPrefix()helper functions inlibs/dyn/dynvar/ref.gobundle/config/validate/scripts.goto allow valid DAB references (${var.x},${bundle.name}, etc.) while rejecting ambiguous patterns like${FOO}$FOOfor env var or${var.FOO}for bundle variable"Why
Previously, all
${...}patterns were blocked in scripts with a generic error message. This made it impossible to use DAB variable interpolation in scripts, forcing users to rely on environment variables as a workaround.With this change:
${var.foo},${bundle.name},${workspace.host}, etc. are now allowed and resolved$HOMEand${VAR:-default}(bash syntax) continue to work${FOO}(ambiguous) shows a helpful error with suggestionsFixes #4179
Tests
bundle/config/validate/scripts_test.golibs/dyn/dynvar/ref_test.goacceptance/bundle/run/scripts/valid-interpolation/acceptance/bundle/run/scripts/no-interpolation/go test ./libs/dyn/dynvar/... ./bundle/config/validate/...make lint(0 issues)